
$(document).ready(function(){
	var rootPath = getRootPath();
	var potentialUserId = '';
	var phone = '';
	var submitDateFrom = '';
	var submitDateEnd = '';
	var startDateFrom = '';
	var startDateEnd = '';
	var appointmentStatus = '';
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/testdrivingAppointment/selectTestDrive?potentialUserId='+potentialUserId+'&phone='+phone+'&submitDateFrom='+submitDateFrom+'&submitDateEnd='+submitDateEnd+'&startDateFrom='+startDateFrom+'&startDateEnd='+startDateEnd+'&appointmentStatus='+appointmentStatus,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(testdrivingIndex,testdrivingObj){
				
				var testdrivingHtml = '';
				
				var appointmentStatus = '';
				
				if(testdrivingObj.appointmentStatus==10011001)
					appointmentStatus = '受理中';
				else if(testdrivingObj.appointmentStatus==10011002)
					appointmentStatus = '已到店';
				else if(testdrivingObj.appointmentStatus==10011003)
					appointmentStatus = '已取消';
				else 
					appointmentStatus = '已确认';
				
				var testdriveAppointmentId = testdrivingObj.testdriveAppointmentId;
				
				testdrivingHtml = testdrivingHtml + '<div class="panel panel-default">'
												  + '<a href="testdrivinginfor.html?testdriveAppointmentId='+testdriveAppointmentId+'" class="list-group-item clearfix">'
												  + '<div style="width:70%;float:left">'
												  + '<p>'+ testdrivingObj.packageCodeName + '</p>'
												  + '<small>试驾时间：' + testdrivingObj.startDate + '</small>'
												  + '</div>'
												  + '<div style="width:20%;float:right">'
												  + '<p>'+ appointmentStatus + '</p>'
												  + '<span class="glyphicon glyphicon-chevron-right"></span>'
												  + '</div>'
												  + '</a>'
												  + '</div>'
				
				wholeHtml += testdrivingHtml;
			});
			
			$("#all").append(wholeHtml);
		}
	});
})
